home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / games / 156 / pascal / newedit.pas next >
Encoding:
Pascal/Delphi Source File  |  1987-07-14  |  3.9 KB  |  94 lines

  1. {$S5}   { set stack space to 5k... }
  2. PROGRAM Newedit;
  3. {**************************************************************************
  4.  PROGRAM COPYRIGHT 1986 OSS.  ALL COMMERCIAL RIGHTS RESERVED.This program is
  5.  in the public domain.  You may give away copies of this program and/or
  6.  source code to anyone willing to take it!  Program sets up mouse in cursor
  7.  key mode then chains original editor, passing original command-line args to
  8.  program.  On exit, restore mouse to mouse mode.  Written 10-28-86 M. Curry.
  9.  <Modified to permit compilation with V.1.02 OSS/PASCAL 20Apr'87 CJPurcell>
  10.         To use this program:
  11.         O.      Rename NEW_EDIT.CJP to NEW_EDIT.PAS
  12.         1.      Compile this program using "Compile and link for TOS" options,
  13.                 thus forming <new_edit.tos> .
  14.    < I had to fix some parameters as noted and replace an omitted brace. CJP>
  15.  <I had to link with paslib,explicitly and then PASLIB,automatically. Why? CJP>
  16.         2.      Rename EDITOR.PRG to EDIT.TTP               <edit.ttp>
  17.         3.      Rename new_edit.tos to EDITOR.PRG.         <editor.prg>
  18.         4.      Edit any source text and move the mouse as appropriate.
  19. Use within OSS/PASCAL environment.The cursor should follow the mouse movements.
  20.         5.      Copy editor.prg to  MOUSEDIT.TTP  for TosTakeParameter usage.
  21. Usage: MOUSEDIT.TTP <filename> [<line> [<column> [<errnum> ]]]mouse is mouse...
  22. For use as a general purpose editor for 'what you see is what you get' editing.
  23. ***************************************************************************}
  24. CONST
  25.    IKBD = 4;     { device number of Keyboard processor }
  26.    LoadAndGo = 0;
  27. TYPE
  28.    Cstring = PACKED ARRAY [ 1..80 ] OF CHAR;
  29. VAR
  30.    RetCode : Integer;   { returned value from editor }
  31. FUNCTION  Bcostat( Dev : Integer ) : Boolean; Bios( 8 );
  32. PROCEDURE Bconout( Dev : Integer; C : Char ); Bios( 3 );
  33. PROCEDURE Pterm( Retval : Integer ); Gemdos( $4c );
  34. FUNCTION Pexec( Mode : Integer;
  35.                 VAR Prog : Cstring;
  36.                 VAR Tail : STRING;
  37.                 Env : Long_Integer ) : Integer;
  38.                                        Gemdos( $4b );
  39. PROCEDURE Make_Cstr( ps : STRING; VAR cs : Cstring);
  40. { convert pascal string ps to C string cs }
  41.   VAR i : Integer;
  42.   BEGIN
  43.     cs[ 1 ] := Chr( 0 );  { set to null for safety }
  44.     FOR i := 1 to Length( ps ) DO
  45.        cs[ i ] := ps[ i ];
  46.     cs[ Length( ps )+1 ] := Chr( 0 );
  47.   END;
  48. PROCEDURE KOUT( C : Integer );               { changed to Integer }
  49. BEGIN
  50.         WHILE NOT Bcostat( IKBD ) DO;      { wait till kbd is ready }
  51.         Bconout( IKBD, Chr(C) );           { send bound char to kbd }
  52. END;
  53. PROCEDURE SetCurs;
  54. BEGIN
  55.    KOUT( $0A  );         { set mouse cursor mode    hex     }
  56.    KOUT( $05  );         {  5 pulses / x movement   hex     }
  57.    KOUT( $0A  );         { 10 pulses / y movement   hex     }
  58. END;
  59. PROCEDURE SetMous;
  60. BEGIN
  61.    KOUT( $08 );          { set mouse mouse mode     hex     }
  62. END;
  63. FUNCTION RunProg : INTEGER;
  64. VAR
  65.    I : Integer;
  66.    Temp,
  67.    CmdLine,
  68.    Args : STRING;
  69.    C_CmdLine : Cstring;
  70. BEGIN
  71.    CmdLine := 'EDIT.TTP';      { new name of original editor program for use }
  72.    Args := '';
  73.    FOR I := 1 to Cmd_Args DO
  74.       BEGIN
  75.          Cmd_GetArg( I, Temp );
  76.          Args := Concat( Args, ' ', Temp )
  77.       END;
  78.    Make_Cstr( CmdLine, C_CmdLine );
  79.    Args := Concat( Args, ' ' );
  80.    Args[ Length( Args ) ] := Chr( 0 );
  81.    Writeln(  Args  );
  82.    RunProg := Pexec( LoadAndGo, C_Cmdline, Args, 0 );
  83. END;
  84. BEGIN                              { introduce ourselves... }
  85.   Writeln( 'MCursor V1.1 From OSS/PASCAL' );
  86.   Writeln( 'Public Domain -- Free to all!' );
  87.   Writeln( 'Help Key and Mouse Cursor Active...' );
  88.   SetCurs;                 { set mouse cursor-mode. }
  89.   RetCode := RunProg;      { run program, copying command line args to it }
  90.   SetMous;                 { set mouse mouse-mode }
  91.   Writeln( 'Mouse is Mouse...' );
  92.   Pterm( RetCode );        { return value to manager }
  93. END.
  94.